<?php
/**
 * Description of iQnItem2HTMLCodeClass
 *
 * @author Jeffy_shih <jeffy@dorise.info>
 * @copyright Copyright(c)2010 DoRISE team, Science Education center, NTNU.
 * @since 2010-05-20
 * @version 1.0
 */
class iQnItem2HTMLCode {
    public function getHTMLCodeByType($strType, $strName, $aryContent) {
        $strRtn = '';
        switch ($strType) {
            case 'text':
                $strRtn = '<input type="text" name="' . $strName . '" size="' . $aryContent[0]  . '" />';
                break;
            case 'radio':
                foreach ($aryContent as $val) {
                    $strRtn .= '<label><input type="radio" name="' . $strName . '[]" />' . $val . '</label>&nbsp;&nbsp;';
                }
                break;
            case 'checkbox':
                foreach ($aryContent as $val) {
                    $strRtn .= '<label><input type="checkbox" name="' . $strName . '[]" />' .$val . '</label>&nbsp;&nbsp;';
                }
                break;
            case 'select':
                $strRtn .= '<select name="' . $strName . '" size="1">';
                $strRtn .= '<option value="N/A">請選擇</option>';
                foreach ($aryContent as $val){
                    $strRtn .= '<option value="' . $val . '">' . $val . '</option>';
                }
                $strRtn .= '</select>';
                break;
            default:
                $strRtn ='No Content Type';
                break;
        }

        return $strRtn;
    }
}
?>
